package visitorPattern.computer

class Computer : ComputerPart {
    /**
     * 定义计算机的组成
     */
    private val part: Array<ComputerPart> = arrayOf(Keyboard(), Mouse(), Display())

    override fun accept(computerPartVisitor: ComputerPartVisitor) {
        part.forEach {
            it.accept(computerPartVisitor)
        }
        computerPartVisitor.visit(this)
    }

    override fun operation() {
        println("我是计算机,你们都是我的一个部件")
    }
}